<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirm-loading="confirmLoading"
    cancel-text="关闭"
    @ok="submit"
    @cancel="closeModal"
  >
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="审核">
          <a-radio-group v-model="action">
            <a-radio :value="0"> 审核不通过 </a-radio>
            <a-radio :value="1"> 审核通过 </a-radio>
          </a-radio-group>
        </a-form-item>
        <a-form-item :label-col="labelCol" :wrapper-col="wrapperCol" label="备注" >
          <a-textarea v-decorator="['reason', {} ]" placeholder="请输入通过/不通过的原因（审核不通过必填）" :rows="4" />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import { Slime } from '@/mixins/slime';
export default {
  name: 'examineModal',
  data() {
    return {
      title: '审核',
      form: this.$form.createForm(this),
      model:{},
      action:0, //1审核通过/0不通过
    };
  },
  mixins: [Slime],
  methods: {
    // 详情
    open() {
      this.visible = true;
    },
    // 提交
    submit() {
      const that = this;
      this.form.validateFields((err, values) => {
        if(that.action == 0 && !values.reason){
          that.$message.warning('审核不通过必须填写备注');
          return false
        }
        if (!err) {
          that.confirmLoading = true;
          const param = {
            ...values,
            action: that.action,
          };
          that.submitUpdate(param);
        }
      });
    },
    // 提交 改
    submitUpdate(param) {
      this.confirmLoading = false;
      this.visible = false;
      this.form.resetFields();
      this.$emit('examineModal', param);
    },
    // 弹窗-关闭
    closeModal() {
      this.confirmLoading = false;
      this.visible = false;
      this.form.resetFields();
      this.$emit('closeModal');
    },
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
</style>